// pages/auth/index.js
import { request } from "../../request/index.js";
import regeneratorRuntime from '../../lib/runtime/runtime';
import { login } from "../../utils/asyncWx.js"
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  async handleGetUserInfo(e) {
    try {


      const { encryptedData, rawData, iv, signature } = e.detail
      const { code } = await login()
      const loginParams = { encryptedData, rawData, iv, signature, code }
      const { token } = await request({ url: "/users/wxlogin", data: loginParams, method: "post" })
      //由于没有企业账号，是获取不到数据的
      wx.setStorageSync("token", token);
      wx.navigateBack({
        delta: 1
      });
    } catch (error) {
      console.log(error);
    }
  },

})